//
//  ViewController.m
//  01-在iOS中调用HTML
//
//  Created by J on 16/2/18.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL* url = [[NSBundle mainBundle]URLForResource:@"index.html" withExtension:nil];
    NSURLRequest* requ = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:requ];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
    //删除
    NSString* str1 = @"var word = document.getElementById('word');"
                "word.remove();";
    [webView stringByEvaluatingJavaScriptFromString:str1];
    
    //改
    NSString* str3 = @"var change = document.getElementsByClassName('change')[0];"
    "change.innerHTML = '好你的哦';";
    [webView stringByEvaluatingJavaScriptFromString:str3];

    
    //插入一张图片
    NSString* str4 = @"var img = document.createElement('img');"
                    "img.src = 'img_01.jpg';"
                    "img.width='60';"
                    "img.height='60';"
                    "document.body.appendChild(img);";
    [webView stringByEvaluatingJavaScriptFromString:str4];

    
    
    
}
@end
